#ifndef _SELECT_H_
#define _SELECT_H_

#include <sys/select.h>
#include "common.h"

class tcp_socket;

class select_engine
{
	public:
		select_engine();
		~select_engine();

		bool fd_add(int fd);
		bool fd_del(int fd);
		bool fd_loop();

	private:
		bool isconnect();
		bool isread();
		int tcp_recv(int fd, void *buf, int len, int flag);
		int tcp_send(int fd, const void *buf, int len, int flag);

	private:
		int 		maxfd;
		int 		maxi;
		int 		sockfd;
		int			nready;
		CLIENTFD	clientfd[10];
		fd_set 		rset;
		fd_set 		allset;
		tcp_socket 	*tcp;
};

#endif
